package com.tuanchau.android.englishtooltip;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import android.app.Application;

public class EnglishToolTipApplication extends Application{
	public static String[]listWord;
	public static String[]listPron;
	
	@Override
	public void onCreate() {
		super.onCreate();
		initPronList();
	}
	
	private void initPronList() {
		if (EnglishToolTipApplication.listWord == null) {
			try {
				BufferedReader reader = new BufferedReader(
						new InputStreamReader(getAssets().open("pron_data.txt")));
				String line = reader.readLine();
				int length = Integer.parseInt(line);
				EnglishToolTipApplication.listPron = new String[length];
				EnglishToolTipApplication.listWord = new String[length];
				
				line = reader.readLine();
				int count = 0;
				String []arr;
				while(line != null) {
					arr = line.split("\t");
					EnglishToolTipApplication.listWord[count] = arr[0];
					EnglishToolTipApplication.listPron[count] = arr[1];
					count++;
					line = reader.readLine();
				}

			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
